﻿using BattleFury.Lib.Managers;
using System.Collections.Generic;
using System.Linq;

namespace BattleFury.Lib.Logs
{
	public class LogManager
		: Manager
	{
		private readonly List<LogMessage> _messages = new List<LogMessage>();

		public LogMessage this[int index]
		{
			get { return _messages[index]; }
		}

		public LogManager()
			: base()
		{
		}

		public void Log(string message)
		{
			_messages.Add(new LogMessage(LogMessageType.Message, message));
		}

		public void Log(LogMessageType type, string message)
		{
			_messages.Add(new LogMessage(type, message));
		}

		public void Clear()
		{
			_messages.Clear();
		}

		public IList<LogMessage> GetMessagesOfType(LogMessageType type)
		{
			return _messages.Where(m => m.Type == type).ToList();
		}
	}
}